/*
 * Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.mrd.gtimpframe.action;

import com.mrd.base.Jqgrid;
import com.mrd.framework.config.web.json.Result;
import com.mrd.gtimpframe.entity.DictionaryGroup;
import com.mrd.gtimpframe.service.DictionaryGroupService;
import com.mrd.util.StringUtils;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

import javax.annotation.Resource;

/**
 * Created by dengdc on 2017/8/1.
 */
@Controller
@RequestMapping("/api/dictionary/group")
public class DictionaryGroupAction {

	@Resource
	private DictionaryGroupService dictionaryGroupService;

	@RequestMapping("/mainPage")
	private String groupMainPage() {
		return "/gtimpframe/dictionaryGroup/main";
	}

	@RequestMapping("/listData")
	@ResponseBody
	public Page<DictionaryGroup> groupListData(Jqgrid jqgrid) {
		return dictionaryGroupService.pageListData(jqgrid);
	}

	@RequestMapping("/addPage")
	private String groupAddPage(Model model,String dtgId) {
		if(StringUtils.isNotEmpty(dtgId)) {
			model.addAttribute(dtgId);
		}
		return "/gtimpframe/dictionaryGroup/detail";
	}

	@RequestMapping("/selectByPkey")
	@ResponseBody
	public DictionaryGroup groupSelectByPkey(String dtgId) {
		return dictionaryGroupService.selectByPrimaryKey(dtgId);
	}

	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	public Result groupSaveOrUpdate(DictionaryGroup dtg) {
		return dictionaryGroupService.saveOrUpdate(dtg);
	}

	@RequestMapping("/dropdownData")
	@ResponseBody
	public List<DictionaryGroup> dropdownData(String key) {
		return dictionaryGroupService.dropdownList(key);
	}
}
